package com.ss.android.article.browser.search;

import android.support.annotation.NonNull;

import com.a.a.NightMode;
import com.a.a.u;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

final class g implements NightMode {
    private final SearchHistoryAdapter d;
    private final List a;
    private final List b;
    private final List c;

    g(SearchHistoryAdapter arg1, List arg2, List arg3, List arg4) {
        this.d = arg1;
        this.a = arg2;
        this.b = arg3;
        this.c = arg4;

    }

    public final void f(@NonNull Object arg7) {
        int v5 = 5;
        ArrayList v0 = new ArrayList(v5);
        if(this.a != null) {
            SearchHistoryAdapter.d(this.d).clear();
            SearchHistoryAdapter.d(this.d).addAll(this.a);
        }

        if(this.b != null) {
            SearchHistoryAdapter.e(this.d).clear();
            SearchHistoryAdapter.e(this.d).addAll(this.b);
        }

        if(this.c != null) {
            SearchHistoryAdapter.f(this.d).clear();
            SearchHistoryAdapter.f(this.d).addAll(this.c);
        }

        Iterator v1 = SearchHistoryAdapter.d(this.d).iterator();
        Iterator v2 = SearchHistoryAdapter.e(this.d).iterator();
        ListIterator v3 = SearchHistoryAdapter.f(this.d).listIterator();
        while(((List)v0).size() < v5) {
            if(!v1.hasNext() && !((Iterator)v3).hasNext() && !v2.hasNext()) {
                break;
            }

            if(v1.hasNext()) {
                ((List)v0).add(v1.next());
            }

            if((((Iterator)v3).hasNext()) && ((List)v0).size() < v5) {
                ((List)v0).add(((Iterator)v3).next());
            }

            if(!v2.hasNext()) {
                continue;
            }

            if(((List)v0).size() >= v5) {
                continue;
            }

            ((List)v0).add(v2.next());
        }

        Collections.sort(((List)v0), SearchHistoryAdapter.g(this.d));
        ((u)arg7).onItem(v0);
        ((u)arg7).onComplete();
    }
}

